#include "CheckBox.h"
#include "../../ImageManager.h"

namespace PickinOpenSticks {
    namespace Ui {

        void CheckBox::Draw(sf::RenderTarget *target) {
            if (!checked) target->Draw(sprite);
            else target->Draw(uncheckedSprite);
        }

        void CheckBox::SetCheckedImage(const std::string& filename) {
            sprite.SetImage(ImageManager::GetSingleton().GetImage(filename, filename));
            pos.w = sprite.GetSize().x;
            pos.h = sprite.GetSize().y;
        }

        void CheckBox::SetUnCheckedImage(const std::string& filename) {
            uncheckedSprite.SetImage(ImageManager::GetSingleton().GetImage(filename, filename));
        }

        void CheckBox::SetDefaultImage() {
            sprite.SetImage(ImageManager::GetSingleton().GetImage("assets/gfx/checkbox1.png", "default_checked"));
            uncheckedSprite.SetImage(ImageManager::GetSingleton().GetImage("assets/gfx/checkbox2.png", "default_unchecked"));

            pos.w = sprite.GetSize().x;
            pos.h = sprite.GetSize().y;
        }
    }
}
